<template>
	<div class="child">
		<h2>我是Child组件</h2>
		<h4>Child组件的msg：{{msg}}</h4>
		<h4>Child组件的address：{{address}}</h4>
		<button @click="sendMsg2App">点我把msg交给我的父组件（其实是触发haha事件）</button>
		<br><br>
		<button @click="sendAddress2App">点我把address交给我的父组件（其实是触发xixi事件）</button>
		<br><br>
		<button @click="jieBang">点我解绑xixi事件（address无法再交给父组件了）</button>
	</div>
</template>

<script>
	export default {
		name:'Child',
		data() {
			return {
				msg:'欢迎来到尚硅谷！',
				address:'宏福科技园'
			}
		},
		methods: {
			sendMsg2App(){
				//谁点的$emit，就触发谁身上的自定义事件
				this.$emit('haha',this.msg)
			},
			sendAddress2App(){
				//谁点的$emit，就触发谁身上的自定义事件
				this.$emit('xixi',this.address)
			},
			jieBang(){
				this.$off(['haha','xixi'])
			}
		},
	}
</script>

<style scoped>
	.child{
		background-color: skyblue;
		padding: 30px;
	}
</style>